<!--#INCLUDE FILE="conn.asp"-->
<!--#INCLUDE FILE="ad_function.asp"-->
<!-- #include file="aFunction_charCode.asp" -->
<!-- #include file="ad_comSub.asp" -->

<%
Call tslt_useridentity12_error_end()
%>

<HTML>
<HEAD>
<TITLE></TITLE>
<link href=../style/<%=session("tslt_stylefolder")%>/admin.css rel="stylesheet" type="text/css">
<SCRIPT language=JavaScript>
<!--
function go(src,q){
         var ret;
         ret = confirm(q);
         if(ret!=false)window.location=src;
}

function SearchDate(){
         if (isNaN(document.form1.keyword.value)){
                 self.alert ("ı,!");
                 form1.keyword.value='';
                 form1.keyword.focus();
                 return false;
          }else{
                 form1.submit();
          }
}

function allDel(){
      var ret = confirm("Ҫɾ<%if request("keyword")<>"" then%><%=request("keyword")%><%else%>90<%end if%>δ¼̳ȫעûǵм¼ԱܴƣزȷʵҪɾȫ");
      <%if request("keyword")<>"" then%>
	        if(ret!=false)window.location.href="sleepuser.asp?isAllDel=<%=request("keyword")%>";
      <%else%>
	        if(ret!=false)window.location.href="sleepuser.asp?isAllDel=90";
      <%end if%>
}
//-->
</SCRIPT>

</HEAD>
<BODY bgcolor=#aaaac4>
<CENTER>
<br>
<table><tr><td class="font2">û</td></tr></table>
<hr width="700">
<br>

<%
if request("User")<>"" or request("p")<>"" then
    If Not HMUser(request.QueryString("User")) Then
       call deluser_articleandnote(request.QueryString("User"))
       call del_id(request.QueryString("User"))
	End If 
    Call infoDivShow("&nbsp;ɾɹ")
    Response.write"<META HTTP-EQUIV='Refresh' content='3; URL=sleepuser.asp'>"
end if

If Request.QueryString("isAllDel")<>"" Then 
    Call isDel(Request.QueryString("isAllDel"))
    Call infoDivShow("&nbsp;ɾɹ")
    Response.write"<META HTTP-EQUIV='Refresh' content='3; URL=sleepuser.asp'>"
End If 
%>

<table bgcolor="#ffffff" border="0">
<form method="POST" name="form1" action="sleepuser.asp">
        <tr>
               <td>
                        <input type="text" name="keyword" size="4" <%if request("keyword")<>"" then%>value=<%=request("keyword")%><%else%>value="90"<%end if%> style="color:red"> δ¼̳û
                        <input type="button" name="submitbtn" value="ȷ" onclick="SearchDate()">  
                        <input type="reset" name="resetbtn" value="">  
               </td>
        </tr>
</form>
</table>

<br>
<table border=1 width=700 bgcolor=#dedfde cellpadding="5" cellspacing="15">
    <tr>
        <td align=center>
            <table border="0" width="100%" cellspacing="1" cellpadding="0" >
               <tr>
                   <td  class=td align="center" height="15" width="10%"><font color="#FF0000">&nbsp;</font></td>
                   <td  class=td align="center" height="15" width=""><font color="#FF0000">û</font></td>
                   <td  class=td align="center" height="15" width="20%"><font color="#FF0000">¼ʱ</font></td>
                   <td  class=td align="center" height="15" width="10%"><font color="#FF0000"></font></td>
                   <td  class=td align="center" height="15" width="10%"><font color="#FF0000">ظ</font></td>
                   <td  class=td align="center" height="15" width="10%"><font color="#FF0000"></font></td>
                   <td  class=td align="center" height="15" width="10%"><font color="#FF0000"></font></td>
               </tr>
<%
               Dim objRS
               Dim strSQL
               Dim keyword2
               keyword2=trim(request("keyword"))
               if keyword2<>"" then
                   strSQL = "SELECT * FROM ts_userinfo where loginNow<(now()-" &keyword2& ") Order By loginNow ASC"
               else
                   strSQL = "SELECT * FROM ts_userinfo WHERE loginNow<(now-90) Order By loginNow ASC"
               end if
               Set objRS = Server.CreateObject("ADODB.Recordset")
               objRS.Open strSQL, Conn, 1, 3
                   If objRS.Eof And objRS.Bof Then
                       Response.write"<SCRIPT language=Javascript>passwords(promptInfo_sleepuser(1))</SCRIPT>"
                   Else
                       Dim totalPage,totalRecordcount
                       objrs.PageSize = showlistok()
                       totalPage=objrs.pagecount 
                       objRS.AbsolutePage=REQUEST("Page")
                       totalRecordcount = objrs.recordcount
                       If Request("Page") <> "" Then   
                           ShowPage objRS,Request("Page"),keyword2
                       Else  
                           ShowPage objRS,1,keyword2
                       End If  
                   End If
%> 
                   <BR>
                   <INPUT TYPE="button" NAME="" value="ȫɾ" onclick="allDel()">

                   <BR>  
                   <BR>  
                   <TABLE width="100%" border="1" style="background-color:#ffffff">
                       <TR><TD>
                               <%call pages()%>
                       </TD></TR>
                   </TABLE>
<%
              objRS.Close
              Set objRS = Nothing
%>
        </td>
    </tr>
</table>

</CENTER>
</BODY>
</HTML>

<%
Call conn_Nothing()

sub pages()
        dim Page      
        Page = Request("Page")
        if Page="" or Page=0 then
                 page=1
        else
                 page=cint(request("page"))
        end if
       if totalRecordcount<>0 then
            dim currid1,currid2
            if totalPage>=10 then
                  if Page mod 10=0 then
                        currid1=Page
                        currid2=Page-9
                  else
                        if totalPage mod 10=0 then 
                               currid1=int(Page/10)*10+10
                        else 
                               if int(Page/10)=int(totalPage/10) then currid1=(totalPage/10)*10 else currid1=int(Page/10)*10+10
                        end if
                        currid2=int(Page/10)*10+1
                  end if
            else 
                  currid1=totalPage mod 10
                  currid2=int(totalPage/10)*10+1
            end if
%>
            <table align=left>
                 <tr><td>
<%
                        if totalPage>1 Then
                              If Page=totalPage or Page<>1 Then 
                                     dim PrwePage
                                     PrwePage=Page-1
                                     Response.Write "<A class=a1 HREF=sleepuser.asp?Page="&PrwePage&"&keyword="&keyword2&"&sel1="&request("sel1")   
                                     Response.Write "><font size=4>һҳ</font></A>  "              
                              End If  
                        End If          
%>
                 </td></tr>
            </table>
            <table border="0" align="left">
                 <tr><td>
                       <FONT face=webdings size=2>
                       <%if Page=1 then%>
                               <span style="color: #FF0000">9</span>
                       <%else%>
                               <a class=a2 href="sleepuser.asp?Page=1<%="&keyword="&keyword2&"&sel1="&request("sel1")%>">9</a>
                       <%end if%>
                       <%if Page>10 then%>
                               <a class=a2 href="sleepuser.asp?Page=<%=currid2-1&"&keyword="&keyword2&"&sel1="&request("sel1")%>">7</a>
                       <%end if%>
                       </FONT>
                       <strong>
<%
                       for i=currid2 to currid1
                            if Page=i then 
	                             response.Write("<font color=red size=4>"&i&"</font>  ")
                            else
%>
                                 <FONT size=2>
                                 <a class=a2 href="sleepuser.asp?Page=<%=i&"&keyword="&keyword2&"&sel1="&request("sel1")%>">
                                        <%response.write i%>
                                 </a>
                                 </FONT>
                            <%end if%>
                            <%response.write " "%>
                       <%next%>
                       </strong>
                       <FONT face=webdings size=2>
                       <%if currid1<totalPage then%>
                             <a class=a2 href="sleepuser.asp?Page=<%=currid1+1&"&keyword="&keyword2&"&sel1="&request("sel1")%>">8</a>
                      <%end if%>
                      </FONT> 
                      <FONT face=webdings size=2>
                      <%if Page=totalPage then%>
                             <span style="color: #FF0000">:</span>
                      <%else%>
                             <a class=a2 href="sleepuser.asp?Page=<%=totalPage&"&keyword="&keyword2&"&sel1="&request("sel1")%>">:</a>
                      <%end if%>
                      </FONT>
                 </td></tr>
            </table>
            <table align=left>
                 <tr><td>
<% 
                        if totalPage>1 Then
                             If page=1 or totalPage>Page Then
                                   dim NextPage
                                   NextPage=Page+1
                                   Response.Write "<A  class=a1 HREF=sleepuser.asp?Page="&NextPage&"&keyword="&keyword2&"&sel1="&request("sel1")
                                   Response.Write "><font size=4>һҳ</font></A>"
                             End If
                        End If
%>
                 </td></tr>
            </table>
            <table align=right>
                 <tr><td>
<%
                       if Page>totalPage then
                            Page=totalPage
                       end if
                      Response.Write "<font size=2>ҳΣ<font color= red><b>"& Page &"</b></font>/<b>"& totalPage &"</b>ҳ ,<b>"& totalRecordcount &"</b></font>"
%>
                </td></tr>
            </table>
<%
        end if
end Sub

Sub ShowPage(objRS,Page,ddd)
       For I = 1 To objRS.PageSize
              Response.Write "<TR height='20'>"
%>
             <td class=td1 align='center'><a class=a1 href="javascript:go('sleepuser.asp?User=<%=objrs("username")%>&p=<%=Request.QueryString("page")%>','棡û&nbsp;&nbsp;<%=objrs("username")%>&nbsp;&nbsp;ǳ&nbsp;&nbsp;<%If ddd<>"" Then%><%=ddd%><%else%>90<%End If%>&nbsp; &nbsp;δ¼̳ûɾû͸ûм¼ԱܴƣزȷҪɾ?')" title="ɾ">ɾ</a></td>
<%
             Response.Write "<td class=td1 align='center'><font size=2>"
             call userStanding(objrs("username"))
             call UserInfoLink(objrs("username"))
             Response.Write "</td>"  
             Response.Write "<td class=td1 align='center'><font size=2>" & objRS("loginNow") & "</td>"
             Response.Write "<td class=td1 align='center'><font size=2>" & objRS("articleTotal") & "</td>"
             Response.Write "<td class=td1 align='center'><font size=2>" & objRS("replyTotal") & "</td>"
             Response.Write "<td class=td1 align='center'><font size=2>" & objRS("UserIntegral") & "</td>"
             Response.Write "<td class=td1 align=center><INPUT TYPE='checkbox' NAME=" &objRS("id")&" id='chk_Id' value='on'></td>"
             Response.Write "</TR>"
             Response.Write "<TR height='6' bgcolor='#fffff8'><td colspan='7'></TR>"
             objRS.MoveNext
             If objRS.EOF Then Exit For
      Next    
      Response.Write "</TABLE>"
End Sub

sub deluser_articleandnote(aa)
       dim sql
       dim rs
       set rs=server.createobject("adodb.recordset")
       sql = "select * FROM article WHERE User='" & aa & "'  Order By id DESc"
       rs.Open sql,conn,1,2
              do while not rs.eof
                      set rs1=server.createobject("adodb.recordset")
                      Dim d_SavePathFileName2
                      sSql = "SELECT d_SavePathFileName FROM article WHERE id = " & rs("id")
                      Rs1.Open sSql, Conn, 0, 1
                             If Not Rs1.Eof Then
                                      d_SavePathFileName2 = Rs1("d_SavePathFileName")
                              End If
                              Dim aSavePathFileName
                              aSavePathFileName = Split(d_SavePathFileName2, "|")
                              Dim i
                              For i = 0 To UBound(aSavePathFileName)
                                       Call DoDelFile(aSavePathFileName(i))
                              Next
                      rs1.close
                      set rs1=nothing
                      rs.movenext
               loop 
       rs.close
       set rs=nothing
        set rs=server.createobject("adodb.recordset")
        sql = "select * FROM article WHERE User='" & aa & "' Order By id DESc"
        rs.Open sql,conn,1,2
           do while not rs.eof
                set rs2=server.createobject("adodb.recordset")  
                Dim r_SavePathFileName2
                rSql = "SELECT r_SavePathFileName FROM reply WHERE cstr(reply_id)= " & rs("id")
                Rs2.Open rSql, Conn, 0, 1
                        do while not rs2.eof
                                 If Not Rs2.Eof Then  
                                          r_SavePathFileName2 = Rs2("r_SavePathFileName")
                                  End If
                                  Dim bSavePathFileName
                                  bSavePathFileName = Split(r_SavePathFileName2, "|")
                                  Dim j
                                  For j = 0 To UBound(bSavePathFileName)
                                          Call DoDelFile(bSavePathFileName(j))
                                   Next
                                   rs2.movenext
                        loop
                rs2.close
                Set RS2 = Nothing
                rs.movenext
          loop
       rs.close
       set rs=nothing
       set rs=server.createobject("adodb.recordset")
       sql = "select * FROM article WHERE User='" & aa & "' Order By id DESc"
       rs.Open sql,conn,1,2
              For i = 1 To RS.recordcount
                     conn.execute("delete FROM reply WHERE cstr(reply_id)='" & rs("id") & "'")
                     RS.MoveNext 
              Next
       rs.close
       set rs=nothing
       conn.execute("delete FROM article WHERE User='" & aa & "'")
       conn.execute("delete FROM reply WHERE reply_human='" & aa & "'")
       conn.execute("delete from [sitenote] where incept='" & aa & "'")
end Sub

Sub del_id(aa)
        conn.execute("delete FROM admin WHERE username='" & aa & "'")
        conn.execute("delete FROM ts_userinfo WHERE username='" & aa & "'")
End Sub

Sub isDel(dayNum)
	Dim rs,sql
    Set rs=server.createobject("adodb.recordset")
    sql = "select * FROM ts_userinfo WHERE loginNow<CDate('" & CLng(now())-dayNum & "')" 
    rs.Open sql,conn,1,2
       Do While Not rs.eof
           If Not HMUser(rs("username")) Then
               Call deluser_articleandnote(rs("username"))
               conn.execute("delete FROM admin WHERE username='" & rs("username") & "'")
		       conn.execute("delete FROM ts_userinfo WHERE username='" & rs("username") & "' And loginNow<CDate('" & CLng(now())-dayNum & "')")
	       End If 
           rs.MoveNext
       Loop 
    rs.close
    Set rs=Nothing
End Sub 

Function HMUser(UName)
    HMUser=False 
    Dim rs
    set rs=conn.Execute("select bclass from ts_userinfo where username='" & UName & "'")
	    If rs("bclass")=1 Then
	       HMUser=True 
		End If 
    rs.close
    Set rs=Nothing
End Function 

%>